package com.ruoyi.personnel.salary.hourly.service;

import com.ruoyi.personnel.salary.hourly.domain.HourlyCond;
import com.ruoyi.personnel.salary.hourly.domain.HourlyDomain;
import com.ruoyi.personnel.salary.hourly.domain.HourlyDto;
import com.ruoyi.personnel.salary.hourly.mapper.HourlyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 工资所得税
 * 业务处理层
 */
@Service
public class HourlyServiceImpl implements IHourlyService{
    @Autowired
    private HourlyMapper hourlyMapper;

    /**
     * 根据搜索条件所有计时工资记录
     * @param cond 搜索条件
     * @return
     */
    @Override
    public List<HourlyDto> selectHourlyList(HourlyCond cond) {
        List<HourlyDto> hourlyDtos = hourlyMapper.selectHourlyList(cond);
        for (int i = 0; i < hourlyDtos.size(); i++) {
            Double totalPrice = hourlyDtos.get(i).getWorkingTime() * hourlyDtos.get(i).getUnitPrice();
            hourlyDtos.get(i).setTotalPrice(totalPrice);
        }
        return hourlyDtos;
    }

    /**
     * 根据员工编号搜索具体的计时工资记录
     * @param staffId 员工编号
     * @return
     */
    @Override
    public HourlyDto selectHourlyById(String staffId) {
        return hourlyMapper.selectHourlyById(staffId);
    }

    /**
     * 新增计时工资记录
     * @param hourly
     * @return
     */
    @Override
    public int insertHourly(HourlyDomain hourly) {
        return hourlyMapper.insertHourly(hourly);
    }

    /**
     * 修改计时工资记录
     * @param hourly
     * @return
     */
    @Override
    public int updateHourly(HourlyDomain hourly) {
        return hourlyMapper.updateHourly(hourly);
    }

    /**
     * 删除计时工资记录
     * 仅修改删除标志
     * @param hourly
     * @return
     */
    @Override
    public int updateHourlyDeleteFlag(HourlyDomain hourly) {
        return hourlyMapper.updateHourlyDeleteFlag(hourly);
    }

//    @Override
//    public Double getHourlyWage(String staffId) {
//        return hourlyMapper.getHourlyWage(staffId);
//    }
}
